import jdk.internal.org.objectweb.asm.Handle;

import java.util.*;

/**
 * @author:gao
 * @date:2020/6/25
 * @time:9:01
 * @version:0.0.1
 * @description:none
 */
//
//public class a {
//
//    public static void main(String[] args) {
//        String s = "leetcode";
//        List<String> list = new ArrayList<>();
//        list.add("leet");
//        list.add("code");
//        Solution solution = new Solution();
//        solution.wordBreak(s,list);
//    }
//}
//
//class Solution {
//
//    //HashSet+回溯+缓存的five解法
////    private Set<String> wordSet;
////    private char[][] cache;
////    private final char UNOP = '0';//未操作
////    private final char OK = '1';//表示可以在set中找到
////    private final char NO = '2';//表示不可以再set中找到
////    public boolean wordBreak(String s, List<String> wordDict) {
////        wordSet = new HashSet<String>();
////        for(String str :wordDict){
////            wordSet.add(str);
////        }
////        cache = new char[s.length()][s.length()];
////        for(int i=0;i<s.length();i++){
////            for(int  j=0;j<s.length();j++){
////                cache[i][j]=UNOP;
////            }
////        }
////        return search(s,0);
////    }
////    private boolean search(String s,int from){
////        if(from==s.length())return true;
////        for(int i=from+1;i<=s.length();i++){
////            if(cache[from][i-1]==NO)continue;
////            String pre = s.substring(from,i);
////            cache[from][i-1] = OK;
////            if(wordSet.contains(pre)){
////                boolean su = search(s,i);
////                if(su) return true;
////                else cache[from][i-1]=NO;
////            }
////        }
////        return false;
////    }
//
//        public boolean wordBreak(String s, List<String> wordDict) {
//            Set<String> wordDictSet = new HashSet(wordDict);
//            boolean[] dp = new boolean[s.length() + 1];
//            dp[0] = true;
//            for (int i = 1; i <= s.length(); i++) {
//                for (int j = 0; j < i; j++) {
//                    if (dp[j] && wordDictSet.contains(s.substring(j, i))) {
//                        dp[i] = true;
//                        break;
//                    }
//                }
//            }
//            return dp[s.length()];
//        }
//
//}
